package de.wittekind.bundesjugendspiele.server;

import java.io.IOException;
import de.wittekind.bundesjugendspiele.basics.Config;
import de.wittekind.bundesjugendspiele.server.modes.Database;
import de.wittekind.bundesjugendspiele.server.modes.RPC;

public class BackendConfig extends Config {
	private final String DATABASE_STRING = "database";
	private final String RPC_STRING = "rpc";
	private final String DB_HOST_STRING = "dbHost";
	private final String DB_USERNAME_STRING = "dbUser";
	private final String DB_PASSWORD_STRING = "dbPassword";
	private final String DB_DATABASE_STRING = "dbDatabase";
	private final String DB_PORT_STRING = "dbPort";
	private final String RMI_NAME_STRING = "rmiName";
	private final String RMI_PORT_STRING = "rmiPort";
	private final String RMI_HOST_STRING = "rmiHost";

	public BackendConfig(String path) throws IOException {
		super(path);
	}

	public Database getDatabase() {
		return Database.valueOf(getString(DATABASE_STRING));
	}

	public void setDatabase(Database db) {
		setString(DATABASE_STRING, db.name());
	}

	public RPC getRPC() {
		return RPC.valueOf(getString(RPC_STRING));
	}

	public void setRPC(RPC rpc) {
		setString(RPC_STRING, rpc.name());
	}

	public String getDbHost() {
		return getString(DB_HOST_STRING);
	}

	public void setDbHost(String dbHost) {
		setString(DB_HOST_STRING, dbHost);
	}

	public String getDbUser() {
		return getString(DB_USERNAME_STRING);
	}

	public void setDbUser(String user) {
		setString(DB_USERNAME_STRING, user);
	}

	public String getDbPassword() {
		return getString(DB_PASSWORD_STRING);
	}

	public void setDbPassword(String password) {
		setString(DB_PASSWORD_STRING, password);
	}

	public String getDbDatabase() {
		return getString(DB_DATABASE_STRING);
	}

	public void setDbDatabase(String db) {
		setString(DB_DATABASE_STRING, db);
	}

	public int getDbPort() {
		return getInteger(DB_PORT_STRING);
	}

	public void setDbPort(int port) {
		setInteger(DB_PORT_STRING, port);
	}

	public String getRMIName() {
		return getString(RMI_NAME_STRING);
	}

	public void setRMIName(String name) {
		setString(RMI_NAME_STRING, name);
	}

	public int getRMIPort() {
		return getInteger(RMI_PORT_STRING);
	}

	public void setRMIPort(int port) {
		setInteger(RMI_PORT_STRING, port);
	}

	public String getRMIHost() {
		return getString(RMI_HOST_STRING);
	}

	public void setRMIHost(String host) {
		setString(RMI_HOST_STRING, host);
	}

}
